package com.sushi.controller;

import com.sushi.service.CommodityService;
import com.sushi.response.ResponseBO;
import com.sushi.response.ResponsePageBO;
import com.sushi.response.CommodityResp;
import com.sushi.request.CommodityReq;
import com.sushi.request.CommodityPageReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.*;

/**
 * 商品 控制器
 * @date 2023-05-02
 * @time 17:13:55
 * @author Administrator
 */
@RestController
@Slf4j
public class CommodityController {

	@Autowired
	private CommodityService commodityService;

    

    /**
     * 新增
     */
    @PostMapping("/commodity/add")
    public ResponseBO<CommodityResp> add(@RequestBody CommodityReq req) {
        return commodityService.add(req);
    }

    /**
     * 逻辑删除
     */
    @PostMapping("/commodity/remove")
    public ResponseBO<CommodityResp> remove(@RequestBody CommodityReq req) {
        return commodityService.logicRemove(req);
    }

    /**
     * 更新
     */
    @PostMapping("/commodity/update")
    public ResponseBO<CommodityResp> update(@RequestBody CommodityReq req) {
        return commodityService.updateByField(req);
    }

    /**
     * 列表
     */
    @PostMapping("/commodity/list")
    public ResponsePageBO<CommodityResp> list(@RequestBody CommodityPageReq req) {
        return commodityService.listByCondition(req);
    }

    /**
     * 详情
     */
    @PostMapping("/commodity/detail")
    public ResponseBO<CommodityResp> detail(@RequestBody CommodityReq req) {
        return commodityService.detail(req);
    };

}